<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>临时文件分享</title>
    <style>
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: #f5f7fa;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            color: #333;
        }
        .container {
            background-color: white;
            border-radius: 10px;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
            padding: 30px;
            width: 90%;
            max-width: 500px;
            text-align: center;
        }
        h1 {
            color: #4a6ee0;
            margin-bottom: 20px;
        }
        p {
            color: #666;
            margin-bottom: 25px;
            line-height: 1.6;
        }
        .upload-area {
            border: 2px dashed #ccc;
            border-radius: 8px;
            padding: 30px 20px;
            margin-bottom: 20px;
            transition: all 0.3s ease;
            cursor: pointer;
        }
        .upload-area:hover, .upload-area.dragover {
            border-color: #4a6ee0;
            background-color: #f0f5ff;
        }
        .upload-icon {
            font-size: 48px;
            color: #4a6ee0;
            margin-bottom: 15px;
        }
        .file-input {
            display: none;
        }
        .btn {
            background-color: #4a6ee0;
            color: white;
            border: none;
            padding: 12px 25px;
            border-radius: 5px;
            cursor: pointer;
            font-size: 16px;
            transition: background-color 0.3s;
        }
        .btn:hover {
            background-color: #3a5ecc;
        }
        .file-info {
            margin-top: 15px;
            font-size: 14px;
            color: #666;
        }
        .features {
            display: flex;
            justify-content: space-around;
            margin-top: 30px;
            text-align: center;
        }
        .feature {
            flex: 1;
            padding: 0 10px;
            max-width: 150px;
        }
        .feature-icon {
            font-size: 24px;
            color: #4a6ee0;
            margin-bottom: 10px;
        }
        .feature-text {
            font-size: 14px;
            color: #666;
        }
        footer {
            margin-top: 30px;
            font-size: 12px;
            color: #999;
        }
    </style>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
</head>
<body>
    <div class="container">
        <h1>临时文件分享</h1>
        <p>上传文件获取临时分享链接，链接将在24小时后自动失效</p>
        
        <form action="/upload" method="post" enctype="multipart/form-data" id="upload-form">
            <div class="upload-area" id="drop-area">
                <div class="upload-icon">
                    <i class="fas fa-cloud-upload-alt"></i>
                </div>
                <p>拖拽文件到这里或点击选择文件</p>
                <input type="file" name="file" id="file-input" class="file-input" required>
                <div class="file-info" id="file-info"></div>
            </div>
            
            <button type="submit" class="btn">上传并获取分享链接</button>
        </form>
        
        <div class="features">
            <div class="feature">
                <div class="feature-icon"><i class="fas fa-clock"></i></div>
                <div class="feature-text">24小时有效期</div>
            </div>
            <div class="feature">
                <div class="feature-icon"><i class="fas fa-lock"></i></div>
                <div class="feature-text">安全传输</div>
            </div>
            <div class="feature">
                <div class="feature-icon"><i class="fas fa-trash-alt"></i></div>
                <div class="feature-text">自动清理</div>
            </div>
        </div>
        
        <footer>
            &copy; 2025 临时文件分享服务 | 最大文件大小: 100MB
        </footer>
    </div>

    <script>
        const dropArea = document.getElementById('drop-area');
        const fileInput = document.getElementById('file-input');
        const fileInfo = document.getElementById('file-info');
        
        // 点击上传区域触发文件选择
        dropArea.addEventListener('click', () => {
            fileInput.click();
        });
        
        // 文件选择后显示文件信息
        fileInput.addEventListener('change', () => {
            if (fileInput.files.length > 0) {
                const file = fileInput.files[0];
                const fileSize = formatFileSize(file.size);
                fileInfo.textContent = `已选择: ${file.name} (${fileSize})`;
            }
        });
        
        // 拖拽事件处理
        ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
            dropArea.addEventListener(eventName, preventDefaults, false);
        });
        
        function preventDefaults(e) {
            e.preventDefault();
            e.stopPropagation();
        }
        
        ['dragenter', 'dragover'].forEach(eventName => {
            dropArea.addEventListener(eventName, () => {
                dropArea.classList.add('dragover');
            }, false);
        });
        
        ['dragleave', 'drop'].forEach(eventName => {
            dropArea.addEventListener(eventName, () => {
                dropArea.classList.remove('dragover');
            }, false);
        });
        
        dropArea.addEventListener('drop', (e) => {
            const dt = e.dataTransfer;
            const files = dt.files;
            
            if (files.length > 0) {
                fileInput.files = files;
                const file = files[0];
                const fileSize = formatFileSize(file.size);
                fileInfo.textContent = `已选择: ${file.name} (${fileSize})`;
            }
        }, false);
        
        // 格式化文件大小
        function formatFileSize(bytes) {
            if (bytes === 0) return '0 Bytes';
            const k = 1024;
            const sizes = ['Bytes', 'KB', 'MB', 'GB'];
            const i = Math.floor(Math.log(bytes) / Math.log(k));
            return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
        }
    </script>
</body>
</html>